#ifndef DIALOGS_H
#define DIALOGS_H

#ifndef MYMESSAGEBOX_GLOBAL_H
#define MYMESSAGEBOX_GLOBAL_H

#include <QtCore/qglobal.h>

#if defined(MYMESSAGEBOX_LIBRARY)
#  define MYMESSAGEBOX_EXPORT Q_DECL_EXPORT
#else
#  define MYMESSAGEBOX_EXPORT Q_DECL_IMPORT
#endif
#endif // MYMESSAGEBOX_GLOBAL_H

#include <QtWidgets/qdialog.h>
#include <QString>
#include <QSplashScreen>
#include <QtCore/QVariant>
#include <QScreen>

namespace Ui {
    class MessageDlg;
    class WaitDlg;
    class SplashScreen;
}

/**
 * @brief 启动页面对象
 */
class MYMESSAGEBOX_EXPORT SplashScreen : public QSplashScreen {

    Q_OBJECT

public:

    /**
     * @param logo              左上角显示的公司logo图片
     * @param projectName       大标题
     */
    SplashScreen(QString projectName = QString(), QWidget* parent = 0);

public slots:

    /**
     * 更新进度信息
     * @param msg       当前正在处理的事情
     * @param progress  当前进度
     */
    void update(QString msg, int progress);

private:

    Ui::SplashScreen *ui;
};

/**
 * @brief 弹框对象
 */
class MessageDlg : public QDialog
{
    Q_OBJECT

public:

    explicit MessageDlg(QWidget *parent = nullptr);

    MessageDlg(QPixmap& icon, QWidget* parent, QString title = QString(), QString text = QString(), QString acceptBtn = QString(), QString rejectBtn = QString());

    ~MessageDlg();

private:
    Ui::MessageDlg *ui;
};

/**
 * @brief 等待对话框
 */
class MYMESSAGEBOX_EXPORT WaitDlg : public QDialog {

    Q_OBJECT

public:

    explicit WaitDlg(QString msg, QWidget *parent = nullptr);

    ~WaitDlg();

    void closeDlg();

private:

    Ui::WaitDlg *ui;

};

/**
 * @brief 调用弹框的对象类
 */
class MYMESSAGEBOX_EXPORT MyMessageBox : public QObject {

       Q_OBJECT

public:

    MyMessageBox();

    static int information(QWidget* parent, QString title = QString(), QString text = QString(), QString acceptBtn = QString(), QString rejectBtn = QString());

    static int warning(QWidget* parent, QString title = QString(), QString text = QString(), QString acceptBtn = QString(), QString rejectBtn = QString());

    static int error(QWidget* parent, QString title = QString(), QString text = QString(), QString acceptBtn = QString(), QString rejectBtn = QString());

    static int question(QWidget* parent, QString title = QString(), QString text = QString(), QString acceptBtn = QString(), QString rejectBtn = QString());

    static WaitDlg *showWait(QString msg = QString("请稍后..."), QWidget*parent=NULL);

    //关闭等待对话框, 并把dlg赋值成NULL
    static void closeWaitDlg(WaitDlg *& dlg);
};



#endif // DIALOGSH_H
